package com.yanqu.road.entity.activity.sonhai.config;

import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class SonHaiBuffConfig {

    /**
     * 活动id
     */
    private int activityId;

    /**
     * 事件ID
     */
    private int id;

    /**
     * 图标id
     */
    private int icon;

    /**
     * 技能类型
     */
    private int buffType;

    /**
     * 事件名称
     */
    private String name;

    /**
     * 事件描述
     */
    private String desc;

    /**
     * 等级
     */
    private int level;

    /**
     * 技能参数
     */
    private String param;
    private List<Integer> paramList = new ArrayList<>();

    private String upgradeParam;
    private List<Integer> upgradeParamList = new ArrayList<>();

    /**
     * 叠加次数
     */
    private int num;

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public int getIcon() {
        return icon;
    }

    public void setBuffType(int buffType) {
        this.buffType = buffType;
    }

    public int getBuffType() {
        return buffType;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getLevel() {
        return level;
    }

    public void setParam(String param) {
        this.param = param;
        if (!StringUtils.isNullOrEmpty(param)) {
            String[] params = param.split("\\|");
            List<Integer> paramList = new ArrayList<>();
            for (String item : params) {
                paramList.add(Integer.parseInt(item));
            }
            this.paramList = paramList;
        }
    }

    public String getParam() {
        return param;
    }

    public List<Integer> getParamList() {
        return paramList;
    }

    public String getUpgradeParam() {
        return upgradeParam;
    }

    public void setUpgradeParam(String upgradeParam) {
        this.upgradeParam = upgradeParam;
        if (!StringUtils.isNullOrEmpty(upgradeParam)) {
            String[] params = upgradeParam.split("\\|");
            List<Integer> paramList = new ArrayList<>();
            for (String item : params) {
                paramList.add(Integer.parseInt(item));
            }
            this.upgradeParamList = paramList;
        }
    }

    public List<Integer> getUpgradeParamList() {
        return upgradeParamList;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public int getNum() {
        return num;
    }

    /**
     * 获取buff加成值
     * @param level
     * @return
     */
    public List<Integer> getBuffValueList(int level) {
        List<Integer> buffValueList = new ArrayList<>();
        for (int i = 0; i < this.paramList.size(); i++) {
            //初始值
            int initValue = this.paramList.get(i);
            //等级加成
            int upgradeValue = this.upgradeParamList.get(i);
            int value = initValue + (level - 1) * upgradeValue;
            buffValueList.add(value);
        }
        return buffValueList;
    }
}
